package com.onefinger.services;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.onefinger.aspect.Cache;
import com.onefinger.aspect.Uncache;
import com.onefinger.domain.Item;
import com.onefinger.domain.Waiter;
import com.onefinger.repository.GenericRepository;

public class WaiterService implements IWaiterService {

	@Autowired
	GenericRepository<Waiter> genericRepository; 
	
	@Cache(cacheKey="waiters", expireTime=0)
	public List<Waiter> list() {
		return genericRepository.getList(Waiter.class);
	}

	
	@Uncache(cacheKey="waiters")
	public boolean save(Waiter waiter) {
		try {
			genericRepository.save(waiter);
		} catch (Exception e) {
			
			return false;
		}
		return true;
	}

	@Uncache(cacheKey="waiters")
	public boolean remove(Waiter waiter) {
		try {
			genericRepository.remove(waiter);
		} catch (Exception e) {
			
			return false;
		}
		return true;
	}

}
